package com.tierstall.client.event;

import com.google.gwt.event.shared.GwtEvent;
import com.tierstall.shared.UserDTO;

public class LoginEvent extends GwtEvent<LoginEventHandler> {
  public static Type<LoginEventHandler> TYPE = new Type<LoginEventHandler>();
  private final boolean save_session;
  private final String session_id;
  private final UserDTO user;
  
  public LoginEvent(boolean save_session, String session_id, UserDTO user){
	  this.save_session = save_session;
	  this.session_id = session_id;
	  this.user = user;
  }
  
  public String getSessionId(){
	  return session_id;
  }
  
  public boolean makeCookie(){
	  return save_session;
  }
  
  public UserDTO getLoggedInUser(){
	  return user;
  }
  
  @Override
  public Type<LoginEventHandler> getAssociatedType() {
    return TYPE;
  }

  @Override
  protected void dispatch(LoginEventHandler handler) {
    handler.onLoginAction(this);
  }
}
